# -*- coding: utf-8 -*-
# @Time    : 2024/3/7 12:08
# @Author  : Liaogan
# @FileName: test.py

from PIL import Image
import pytesseract

# 指定 Tesseract 可执行文件的路径
# pytesseract.pytesseract.tesseract_cmd = r'D:\tools\Tesseract-OCR\tesseract.exe'

image_path = r"D:\huawang-api\po\shanli\windows_ui\Dispatching_Desk\cropped_screenshot.png"
img = Image.open(image_path)

text = pytesseract.image_to_string(img)
print(text)

#
# from airtest.core.api import *
# from PIL import Image
#
# # 初始化Airtest
# auto_setup(__file__)

# 进行一些操作，确保你的应用或游戏处于需要截图的状态

# 截取整个屏幕
# screenshot = snapshot()
#
# # 定义截取的区域（左上角和右下角的坐标）
# left_top = (100, 100)
# right_bottom = (300, 300)
#
# # 根据定义的区域裁剪截图
# cropped_image = screenshot.crop(left_top + right_bottom)
#
# # 保存截图
# cropped_image.save("cropped_screenshot.png")


# def demo():
#     # 打开要识别的图片
#     image = Image.open(image_path)
#     # 使用pytesseract调用image_to_string方法进行识别，传入要识别的图片，lang='chi_sim'是设置为中文识别，
#     text = pytesseract.image_to_string(image, lang='chi_sim')
#
#     # 输入所识别的文字
#     print(text)
#
# if __name__ == '__main__':
#     demo()